<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ include file="../general/header.jsp" %>

<script type="text/javascript">
	function copyToClipboard() {
		window.prompt("Apriete Ctrl+C y luego Enter: ", "${emails}");
	}
</script>

	<h3>Resultados de b&uacute;squeda: <c:out value="${searchName}" /></h3>
	<form:form method="POST" action="../data/SaveActions" commandName="massiveSaveForm" >
		<div class="menuacciones">
			<c:if test="${!empty users}">
				<input class="boton" type="submit" value="Exportar" name="export" />
				<c:if test="${searchName=='' || searchName==null}">
					<button class="boton" onclick="jQuery('.overlay').fadeIn(); jQuery('.popupguardar').fadeIn(); return false;" />Guardar</button>
				</c:if>
				<input class="boton" type="button" value="Copiar todos los e-mails" onclick="copyToClipboard()" />
			</c:if>
			<a class="boton volver color" href="../search/Search">Volver</a>
		</div>
		<div class="featurebox_center" id="search">
			<c:choose>
				<c:when test="${empty users}">
					<h2>No hay resultados para la b&uacute;squeda realizada.</h2>
				</c:when>
				<c:otherwise>
					<div class="popup popupguardar">
						<p>Elija un perfil de b&uacute;squeda</p>
						<c:choose>
							<c:when test="${empty profiles}">
								<div class="messages">
									<p class="ok">No tienes perfiles de b&uacute;squeda creados. Crea uno <a href="../data/NewSearchProfile">aqu&iacute;.</a></p>
								</div>
							</c:when>
							<c:otherwise>
								<select name="profileId" size="1">
									<c:forEach items="${profiles}" var="profile">  
										<option value="${profile.id}">${profile.name}</option>  
									</c:forEach>
								</select>	
							</c:otherwise>
						</c:choose>
						<div class="clear"></div>
						<input class="boton" type="submit" value="Guardar en perfil" name="save" />
					</div>
					<div class="messages">
						<form:errors class="error" path="usersSelected" />
					</div>
					<div class="seleccionar">
						<a href="#" onclick="selectAll(); return false;">Seleccionar todos</a>&nbsp;&nbsp;&nbsp;&nbsp;
						<a href="#" onclick="unselectAll(); return false;">Deseleccionar todos</a>
					</div>
					<div class="clear"></div>
					<ul class="usuarios">
						<c:forEach var="user" items="${users}">
							<c:set var="link" value="../user/viewProfile?userid=${user.id}" />
							<c:set var="showCheckBox" value="true" />
							<c:set var="linkText" value="Ver Perfil"/>
							<%@ include file="./user.jsp" %>
						</c:forEach>
						<div class="clear"></div>
					</ul>
				</c:otherwise>
			</c:choose>
		</div>
	</form:form>
	
<%@ include file="../general/footer.jsp" %>

